<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>新建公众号二维码</title>
	<link rel="stylesheet" href="/layui/css/layui.css">
	<link rel="stylesheet" href="/fission/css/iconfont.css">
	<style type="text/css">
		body{
			background: #e9e9e9; 
		}
		/*公共头部带搜索*/
		.public_container{
			margin: 20px;
			background: #fff;
		}
		.public_title_container{
			height: 54px;
			padding: 0 20px;
			font-size: 14px;
			display: flex;
			align-items: center;
			background: #f9f9f9;
			border-bottom: 1px solid #f0f0f0;
			justify-content: space-between;
		}
		.public_title_container a{
			fill: #999;
		}
		/*公共表单部分*/
		.public_form_container{
			padding: 20px 20px 40px 20px;
		}
		.public_form_content{
			padding: 24px 40px 24px 0;
			background: #fff;
			border: 1px solid #e9e9e9;
			margin-bottom: 8px;
		}
		.public_form_List{
			margin-bottom: 10px;
		}
		.public_form_List:last-child{
			margin-bottom: 0px;
		}
		.public_formTitle_container lable{
			font-size: 13px;
			font-weight: bold;
		}
		.service-card {
			padding: 0 7px;
			color: rgba(0,0,0,.65);
			line-height: 28px;
			font-size: 13px;
			display: inline-block;
			margin: 0 8px 0 5px;
			-webkit-box-sizing: border-box;
			box-sizing: border-box;
			white-space: nowrap;
			background: #fafafa;
			border: 1px solid #e9e9e9;
			border-radius: 4px;
			position: relative;
		}
		.service-card i {
			font-size: 14px;
			display: inline-block;
			color: #7da3d1;
			margin-right: 2px;
		}
		.service-card .close {
			position: absolute;
			top: -13px;
			right: -8px;
			opacity: .6;
			cursor: pointer;
		}
		.service-card .close:hover {
			opacity: 1;
		}
		.layui-form-label{
			width: 100px;
		}
		.layui-input-block{
			margin-left: 130px !important;
		}
	</style>
</head>
<body>
	<form class="layui-form" id="form1">
		<div class="public_container">
			<!-- /*公共头部带搜索*/ -->
			<div class="public_content">
				<div class="public_title_container">
					<p>基本信息</p>
					<a href="javascript:history.back(-1)">
						<svg t="1599462684269" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8055" width="20" height="20"><path d="M501.2992 273.408l1.024-156.16L184.65792 379.904l314.29632 266.1376 0.95232-149.2992c313.86624 42.5984 178.29888 231.3216-0.5632 410.2144 619.5712-404.3776 251.01312-590.6432 1.95584-633.5488z" p-id="8056"></path></svg>
					</a>
				</div>

			</div>
			<!-- 公共表单部分 -->
			<div class="public_form_container">
				<div class="public_form_List">
					<div class="public_formTitle_container">
						<lable class="layui-form-label">标题名称：</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block">
							<input type="text" name="title" value="{$customqr->title}" required  lay-verify="required" placeholder="请输入标题名称" autocomplete="off" class="layui-input">
						</div>
					</div>
				</div>
				<div class="public_form_List" id="verificationContainer" >
					<div class="public_formTitle_container">
						<lable class="layui-form-label">使用人员：</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block">
							<span class="layui-btn layui-btn-primary" id="addPeople">+ 前往添加</span>
						</div>
						<div class="flex align-start" style="padding: 6px 5px 0px 105px;" id="checkUserCon">
							{if $customqr->id}
							<div class="service-card">
								<i class="iconfont icon-person"></i>{$h->get_user_by_id($customqr->wid,$customqr->user_id)['name']}
							</div>
							{/if}
						</div>
					</div>
					<input type="hidden" name="checkUser" value="{$customqr->user_id}" id="checkUser"/>
				</div>

				<div class="public_form_List">
					<div class="public_formTitle_container">
						<lable class="layui-form-label">自动打标签：</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block" id="autoLable">
						  <input type="checkbox" lay-filter="autoLable" name="auto_label" lay-skin="switch" {if $customqr->auto_label == 1} checked {/if}>
						</div>
					</div>
				</div>
				<div class="public_form_List" id="autoLableContainer" {if $customqr->auto_label != 1} style="display:none;" {/if}>
					<div class="public_formTitle_container">
						<lable class="layui-form-label">选择标签：</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block">
							<span class="layui-btn layui-btn-primary" id="addLable">+ 添加标签</span>
						</div>
						<div class="flex align-start" style="padding: 6px 5px 0px 105px;" id="checkLableCon">
						    {loop json_decode($customqr->checkLable,1) as $lable}
    							<div class="service-card">{$h->get_et_tags($customqr->wid)[$lable]}</div>
    						{/loop}
						</div>
					</div>
					<input type="hidden" name="checkLable" value="{implode(',',json_decode($customqr->checkLable,1))}" id="checkLable"/>
				</div>
			</div>
		</div>
		<div class="public_container">
			<!-- /*公共头部带搜索*/ -->
			<div class="public_content">
				<div class="public_title_container">
					<p>链接</p>
				</div>

			</div>
			<div class="public_form_container">
				<div class="public_form_List">
					<div class="public_formTitle_container">
						<lable class="layui-form-label">跳转链接：</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block">
							<input type="text" name="url" value="{$customqr->url}"  placeholder="请输入跳转链接" autocomplete="off" class="layui-input">
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="public_container">
			<!-- /*公共头部带搜索*/ -->
			<div class="public_content">
				<div class="public_title_container">
					<p>欢迎语配置</p>
				</div>

			</div>
			<div class="public_form_container">
				<div class="public_form_List">
					<div class="public_formTitle_container">
						<lable class="layui-form-label">欢迎语：</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block" id="welcome">
						  <input type="checkbox" lay-filter="welcome" name="is_welcome" lay-skin="switch" {if $customqr->is_welcome == 1} checked {/if}>
						</div>
					</div>
				</div>
				<div class="public_form_List" id="welcomeContainer"  {if $customqr->is_welcome != 1} style="display:none;" {/if}>
					<div class="public_formTitle_container">
						<lable class="layui-form-label">文字：</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block">
							<div class="insert-btn">
			                 	 <button id="insert" class="layui-btn layui-btn-primary" style="margin-bottom: 5px" type="button" unselectable="on" onmousedown="return false">插入客户名</button>
			                </div>
						  <div contenteditable="true" id="edit_hy_text_content_div" name="edit_hy_text_content_div" class="layui-textarea">{json_decode($customqr->welcome_text,1)}</div>
						</div>
					</div>
					<input type="text" hidden name="welcome_text" id="welcome_text">
				</div>
				<div class="public_form_List">
					<div class="public_formTitle_container">
						<lable class="layui-form-label">标题：</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block">
							<input type="text" name="text_title" value="{$customqr->text_title}"  id="part_time_otype_mp_name" required   placeholder="请输入图文标题" autocomplete="off" lay-verify="required"  class="layui-input part-time-form-elem">
						</div>
					</div>
				</div>
				<div class="public_form_List">
					<div class="public_formTitle_container">
						<lable class="layui-form-label">图文链接：</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block">
							<input type="text" name="text_url"  value="{$customqr->text_url}" id="part_time_otype_mp_appid" required   placeholder="请输入图文链接" autocomplete="off" lay-verify="required"  class="layui-input part-time-form-elem">
						</div>
					</div>
				</div>
				<div class="public_form_List">
					<div class="public_formTitle_container">
						<lable class="layui-form-label">图文描述：</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block">
							<input type="text" name="text_content" value="{$customqr->text_content}" id="part_time_otype_mp_path" required   placeholder="请输入图文描述" autocomplete="off" lay-verify="required"  class="layui-input part-time-form-elem">
						</div>
					</div>
				</div>
				<div class="public_form_List">
					<div class="public_formTitle_container">
						<lable class="layui-form-label">图文封面：</lable>
					</div>
					<div class="public_formOther_container">
						<div class="layui-input-block">
							<img onerror="this.style.display='none'" id="pic_image" class="part-time-img-preview" src="{$customqr->text_image}" style="width: 100px; height: 100px;">
							<input type="hidden" name="text_image" value="{$customqr->text_image}" id="image" class="part-time-form-elem" required lay-verify="required" />
							<button type="button" class="layui-btn part-time-btn-simg" onclick="select_img(this)" data-target="image">
								<i class="layui-icon">&#xe67c;</i>上传图片
							</button>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="public_container">
			<!-- /*公共头部带搜索*/ -->
			<div class="public_content">
				<div class="public_title_container">
					<p>欢迎语附件配置</p>
				</div>
			</div>
			<div class="public_form_container">
				<div id="part-time-lists" >
					<div class="part-time-lists" style="margin-top: 20px;margin-left: 0px;">
						{if count($customqr->welcome_list) >= 1}
							{loop $customqr->welcome_list as $key=>$list}
								<div class="public_form_List part-time-items" style="position: relative;margin-bottom: 20px;">
									<div class="public_formTitle_container">
										<lable class="layui-form-label part-time-item-indexs">附件{$key+1}：</lable>
									</div>
									<div class="public_formOther_container">
										<div class="layui-input-block" style="padding:10px 20px;background:#fdfdfd;border:1px solid #e5e5e5;">
											<div class="layui-input-block part-time-otype-radiobox" style="margin-left: 0;margin-bottom: 10px;">
												<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types{$key+1}" value="1" title="无" {if $list['type'] == 1} checked {/if}>
												<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types{$key+1}" value="2" title="图片" {if $list['type'] == 2} checked {/if}>
												<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types{$key+1}" value="3" title="图文" {if $list['type'] == 3} checked {/if}>
												<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types{$key+1}" value="4" title="小程序" {if $list['type'] == 4} checked {/if}>
											</div>
											<!-- 图片 -->
											<div class="public_form_List part-time-otype-items part_time_otype_imgs" {if $list['type'] != 2} style="display: none;" {/if} >
												<div class="public_formTitle_container">
													<lable class="layui-form-label">图片：</lable>
												</div>
												<div class="public_formOther_container">
													<div class="layui-input-block">
														<img onerror="this.style.display='none'" id="preview_part_time_otype_imgs{$key+1}" class="part-time-img-previews" src="{$list['image']}" style="width: 100px; height: 100px;">
														<input type="hidden" name="image{$key+1}" id="part_time_otype_imgs{$key+1}" class="part-time-form-elems" value="{$list['image']}" />
														<button type="button" class="layui-btn part-time-btn-simgs" data-target="part_time_otype_imgs{$key+1}" onclick="select_img(this)">
															<i class="layui-icon">&#xe67c;</i>上传图片
														</button>
													</div>
												</div>
											</div>
											<!-- 图文 -->
											<div class="public_form_List part-time-otype-items part_time_otype_imgtexts" {if $list['type'] != 3} style="display: none;" {/if}>
												<div class="public_form_List">
													<div class="public_formTitle_container">
														<lable class="layui-form-label">标题：</lable>
													</div>
													<div class="public_formOther_container">
														<div class="layui-input-block">
															<input type="text" name="link_title{$key+1}" id="part_time_otype_it_ltitles{$key+1}"  placeholder="请输入标题" autocomplete="off" class="layui-input part-time-form-elems" value="{$list['title']}">
														</div>
													</div>
												</div>
												<div class="public_form_List">
													<div class="public_formTitle_container">
														<lable class="layui-form-label">链接：</lable>
													</div>
													<div class="public_formOther_container">
														<div class="layui-input-block">
															<input type="text" name="link_url{$key+1}" id="part_time_otype_it_lurls{$key+1}"  placeholder="请输入链接" autocomplete="off" class="layui-input part-time-form-elems" value="{$list['url']}">
														</div>
													</div>
												</div>
												<div class="public_form_List">
													<div class="public_formTitle_container">
														<lable class="layui-form-label">封面：</lable>
													</div>
													<div class="public_formOther_container">
														<div class="layui-input-block">
															<img onerror="this.style.display='none'" id="preview_part_time_otype_it_lpics{$key+1}" class="part-time-img-previews" src="{$list['picurl']}" style="width: 100px; height: 100px;">
															<input type="hidden" name="link_pic{$key+1}" id="part_time_otype_it_lpics{$key+1}" class="part-time-form-elems" value="{$list['picurl']}"/>
															<button type="button" class="layui-btn part-time-btn-simgs" onclick="select_img(this)" data-target="part_time_otype_it_lpics{$key+1}">
																<i class="layui-icon">&#xe67c;</i>上传图片
															</button>
														</div>
													</div>
												</div>
												<div class="public_form_List">
													<div class="public_formTitle_container">
														<lable class="layui-form-label">描述：</lable>
													</div>
													<div class="public_formOther_container">
														<div class="layui-input-block">
															<input type="text" name="link_desc{$key+1}" id="part_time_otype_it_ldesc{$key+1}" placeholder="请输入描述" autocomplete="off" class="layui-input part-time-form-elems" value="{$list['describe']}">
														</div>
													</div>
												</div>
											</div>
											<!-- 小程序 -->
											<div class="public_form_List part-time-otype-items part_time_otype_mps" {if $list['type'] != 4} style="display: none;" {/if}>
												<div class="public_form_List">
													<div class="public_formTitle_container">
														<lable class="layui-form-label">小程序名称：</lable>
													</div>
													<div class="public_formOther_container">
														<div class="layui-input-block">
															<input type="text" name="miniprogram_name{$key+1}" id="part_time_otype_mp_names{$key+1}"    placeholder="请输入小程序名称" autocomplete="off" class="layui-input part-time-form-elems" value="{$list['name']}">
														</div>
													</div>
												</div>
												<div class="public_form_List">
													<div class="public_formTitle_container">
														<lable class="layui-form-label">小程序ID：</lable>
													</div>
													<div class="public_formOther_container">
														<div class="layui-input-block">
															<input type="text" name="miniprogram_appid{$key+1}" id="part_time_otype_mp_appids{$key+1}"    placeholder="请输入ID" autocomplete="off" class="layui-input part-time-form-elems" value="{$list['appid']}">
														</div>
													</div>
												</div>
												<div class="public_form_List">
													<div class="public_formTitle_container">
														<lable class="layui-form-label">小程序路径：</lable>
													</div>
													<div class="public_formOther_container">
														<div class="layui-input-block">
															<input type="text" name="miniprogram_page{$key+1}" id="part_time_otype_mp_paths{$key+1}"    placeholder="请输入小程序路径" autocomplete="off" class="layui-input part-time-form-elems" value="{$list['page']}">
														</div>
													</div>
												</div>
												<div class="public_form_List">
													<div class="public_formTitle_container">
														<lable class="layui-form-label">小程序标题：</lable>
													</div>
													<div class="public_formOther_container">
														<div class="layui-input-block">
															<input type="text" name="miniprogram_title{$key+1}" id="part_time_otype_mp_titles{$key+1}"    placeholder="请输入标题" autocomplete="off" class="layui-input part-time-form-elems" value="{$list['title']}">
														</div>
													</div>
												</div>
												<div class="public_form_List">
													<div class="public_formTitle_container">
														<lable class="layui-form-label">小程序封面：</lable>
													</div>
													<div class="public_formOther_container">
														<div class="layui-input-block">
															<img onerror="this.style.display='none'" id="preview_part_time_otype_mp_pics{$key+1}" class="part-time-img-previews" src="{$list['image']}" style="width: 100px; height: 100px;">
															<input type="hidden" name="miniprogram_pic{$key+1}" id="part_time_otype_mp_pics{$key+1}" class="part-time-form-elems" value="{$list['image']}" />
															<button type="button" class="layui-btn part-time-btn-simgs" onclick="select_img(this)" data-target="part_time_otype_mp_pics{$key+1}">
																<i class="layui-icon">&#xe67c;</i>上传图片
															</button>
														</div>
													</div>
												</div>
											</div>
											<!-- 删除 -->
											<button type="button" class="layui-btn layui-btn-sm layui-btn-primary part-time-item-dels" style="position: absolute;z-index: 9;right: 0px;bottom: 0;">
												<i class="layui-icon">&#xe640;</i>
											</button>
										</div>
									</div>
								</div>
							{/loop}
						{else}
							<div class="public_form_List part-time-items" style="position: relative;margin-bottom: 20px;">
								<div class="public_formTitle_container">
									<lable class="layui-form-label part-time-item-indexs">附件1：</lable>
								</div>
								<div class="public_formOther_container">
									<div class="layui-input-block" style="padding:10px 20px;background:#fdfdfd;border:1px solid #e5e5e5;">
										<div class="part-time-otype-radiobox" style="margin-left: 0;margin-bottom: 10px;">
											<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types1" value="1" title="无" checked>
											<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types1" value="2" title="图片">
											<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types1" value="3" title="图文">
											<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types1" value="4" title="小程序">
										</div>
										<!-- 图片 -->
										<div class="public_form_List part-time-otype-items part_time_otype_imgs" style="display: none;">
											<div class="public_formTitle_container">
												<lable class="layui-form-label">图片：</lable>
											</div>
											<div class="public_formOther_container">
												<div class="layui-input-block">
													<img onerror="this.style.display='none'" id="preview_part_time_otype_imgs1" class="part-time-img-previews" src="" style="width: 100px; height: 100px;">
													<input type="hidden" name="image1" id="part_time_otype_imgs1" class="part-time-form-elems" />
													<button type="button" class="layui-btn part-time-btn-simgs" data-target="part_time_otype_imgs1" onclick="select_img(this)">
														<i class="layui-icon">&#xe67c;</i>上传图片
													</button>
												</div>
											</div>
										</div>
										<!-- 图文 -->
										<div class="public_form_List part-time-otype-items part_time_otype_imgtexts" style="display: none;">
											<div class="public_form_List">
												<div class="public_formTitle_container">
													<lable class="layui-form-label">标题：</lable>
												</div>
												<div class="public_formOther_container">
													<div class="layui-input-block">
														<input type="text" name="link_title1" id="part_time_otype_it_ltitles1"  placeholder="请输入标题" autocomplete="off" class="layui-input part-time-form-elems">
													</div>
												</div>
											</div>
											<div class="public_form_List">
												<div class="public_formTitle_container">
													<lable class="layui-form-label">链接：</lable>
												</div>
												<div class="public_formOther_container">
													<div class="layui-input-block">
														<input type="text" name="link_url1" id="part_time_otype_it_lurls1"  placeholder="请输入链接" autocomplete="off" class="layui-input part-time-form-elems">
													</div>
												</div>
											</div>
											<div class="public_form_List">
												<div class="public_formTitle_container">
													<lable class="layui-form-label">封面：</lable>
												</div>
												<div class="public_formOther_container">
													<div class="layui-input-block">
														<img onerror="this.style.display='none'" id="preview_part_time_otype_it_lpics1" class="part-time-img-previews" src="" style="width: 100px; height: 100px;">
														<input type="hidden" name="link_pic1" id="part_time_otype_it_lpics1" class="part-time-form-elems" />
														<button type="button" class="layui-btn part-time-btn-simgs" onclick="select_img(this)" data-target="part_time_otype_it_lpics1">
															<i class="layui-icon">&#xe67c;</i>上传图片
														</button>
													</div>
												</div>
											</div>
											<div class="public_form_List">
												<div class="public_formTitle_container">
													<lable class="layui-form-label">描述：</lable>
												</div>
												<div class="public_formOther_container">
													<div class="layui-input-block">
														<input type="text" name="link_desc1" id="part_time_otype_it_ldesc1"    placeholder="请输入描述" autocomplete="off" class="layui-input part-time-form-elems">
													</div>
												</div>
											</div>
										</div>
										<!-- 小程序 -->
										<div class="public_form_List part-time-otype-items part_time_otype_mps" style="display: none;">
											<div class="public_form_List">
												<div class="public_formTitle_container">
													<lable class="layui-form-label">小程序名称：</lable>
												</div>
												<div class="public_formOther_container">
													<div class="layui-input-block">
														<input type="text" name="miniprogram_name1" id="part_time_otype_mp_names1"    placeholder="请输入小程序名称" autocomplete="off" class="layui-input part-time-form-elems">
													</div>
												</div>
											</div>
											<div class="public_form_List">
												<div class="public_formTitle_container">
													<lable class="layui-form-label">小程序ID：</lable>
												</div>
												<div class="public_formOther_container">
													<div class="layui-input-block">
														<input type="text" name="miniprogram_appid1" id="part_time_otype_mp_appids1"    placeholder="请输入ID" autocomplete="off" class="layui-input part-time-form-elems">
													</div>
												</div>
											</div>
											<div class="public_form_List">
												<div class="public_formTitle_container">
													<lable class="layui-form-label">小程序路径：</lable>
												</div>
												<div class="public_formOther_container">
													<div class="layui-input-block">
														<input type="text" name="miniprogram_page1" id="part_time_otype_mp_paths1"    placeholder="请输入小程序路径" autocomplete="off" class="layui-input part-time-form-elems">
													</div>
												</div>
											</div>
											<div class="public_form_List">
												<div class="public_formTitle_container">
													<lable class="layui-form-label">小程序标题：</lable>
												</div>
												<div class="public_formOther_container">
													<div class="layui-input-block">
														<input type="text" name="miniprogram_title1" id="part_time_otype_mp_titles1"    placeholder="请输入标题" autocomplete="off" class="layui-input part-time-form-elems">
													</div>
												</div>
											</div>
											<div class="public_form_List">
												<div class="public_formTitle_container">
													<lable class="layui-form-label">小程序封面：</lable>
												</div>
												<div class="public_formOther_container">
													<div class="layui-input-block">
														<img onerror="this.style.display='none'" id="preview_part_time_otype_mp_pics1" class="part-time-img-previews" src="" style="width: 100px; height: 100px;">
														<input type="hidden" name="miniprogram_pic1" id="part_time_otype_mp_pics1" class="part-time-form-elems" />
														<button type="button" class="layui-btn part-time-btn-simgs" onclick="select_img(this)" data-target="part_time_otype_mp_pics1">
															<i class="layui-icon">&#xe67c;</i>上传图片
														</button>
													</div>
												</div>
											</div>
										</div>
										<!-- 删除 -->
										<button type="button" class="layui-btn layui-btn-sm layui-btn-primary part-time-item-dels" style="position: absolute;z-index: 9;right: 0px;bottom: 0;">
											<i class="layui-icon">&#xe640;</i>
										</button>
									</div>
								</div>
							</div>
						{/if}
					</div>
					<input type="hidden" id="partTimeCounts" name="part_time_counts" value="{count($customqr->welcome_list)?count($customqr->welcome_list):1}" />
					<div class="layui-form-item">
						<label class="layui-form-label"></label>
						<div class="layui-input-block">
							<button type="button" class="layui-btn layui-btn-primary part-time-btn-adds"style="color: #1E9FFF;border: 0;background: transparent;"><i class="layui-icon">&#xe608;</i> 添加附件
							</button>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block" style="margin-left: 170px !important;">
				<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
			</div>
		</div>
	</form>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.1.0/jquery.js"></script>
<script src="/layui/layui.js"></script>
<script src="/js/ajax.js"></script>
<script type="text/javascript">
// 添加时间段
function addOnePartTimes() {
	var $items = $('.part-time-lists .part-time-items')
	var length = $items.length
	if($('.part-time-lists .part-time-items').length >= 8){
		layer.msg('最多只能有九个附件')
		return false;
	}
	var tpl = $items.eq(0).clone(false)
		setPartTimeItemIds(tpl, length + 1, true)
		$(".part-time-lists").append(tpl)
		layui.form.render()
		setCounts(length + 1)
}
function setPartTimeItemIds($item, index, clear) {
	$item.find('.part-time-item-indexs').text('附件' + index + '：')
	var $inputs = $item.find('.part-time-form-elems')
	for (var i = 0, l = $inputs.length; i < l; i++) {
		var $theInput = $($inputs[i])
		if (clear && $theInput.attr('type') !== 'radio') {
			$theInput.val('')
		}
		setElemAttrs($theInput, index)
	}
	var $prevImgs = $item.find('.part-time-img-previews')
	for (var i = 0, l = $prevImgs.length; i < l; i++) {
		setElemAttrs($($prevImgs[i]), index)
	}
	var $sImgBtns = $item.find('.part-time-btn-simgs')
	for (var i = 0, l = $sImgBtns.length; i < l; i++) {
		setElemAttrs($($sImgBtns[i]), index)
	}
	return $item
}
function setElemAttrs($elem, index) {
	var id = $elem.attr('id'), name = $elem.attr('name'), _name = $elem.attr('_name'), dataTarget = $elem.attr('data-target'), layKey = $elem.attr('lay-key'), xmSelect = $elem.attr('xm-select');
	var reg = /([0-9]+)/g
	$elem.attr({
		id: id && (id.replace(reg, '') + index),
		name: name && (name.replace(reg, '') + index),
		'data-target': dataTarget && (dataTarget.replace(reg, '') + index), // 上传图片按钮
		'_name': _name && (_name.replace(reg, '') + index), // 日期多选
		'xm-select': xmSelect && (xmSelect.replace(reg, '') + index), // 日期多选
		'lay-key': layKey ? (String(index) + Date.now()) : layKey, // 时间选择器
	});
}
// 添加时间段按钮
$('.part-time-btn-adds').on('click', addOnePartTimes)
// 删除时间段
$('.part-time-lists').on('click', '.part-time-item-dels', function() {
	if ($('.part-time-lists .part-time-items').length <= 1) {
		layer.msg('至少需要一个附件信息，不可删除')
	} else {
		$(this).parent().parent().parent().remove()
		updateItemsOrders()
	}
})
function updateItemsOrders() {
	var $items = $('.part-time-lists .part-time-items')
	var l = $items.length
	setCounts(l)
	for (var i = 0; i < l; i++) {
		var $theItem = $($items[i])
		setPartTimeItemIds($theItem, i + 1, false)
	}
	layui.form.render()
}

function setCounts(n) {
	if (n === undefined) {
		n = $('.part-time-lists .part-time-items').length
	}console.log(n);
	$('#partTimeCounts').val(n)
}

layui.use('form', function(){
	var form = layui.form;
  // 其他类型 切换
  form.on('radio(partTimeOtherTypes)', function (data) {
		var $itemWrap = $(this).parents('.part-time-items')
		var val = $itemWrap.find('input[lay-filter="partTimeOtherTypes"]:checked').val()

		$itemWrap.find('.part-time-otype-items').hide()
		$itemWrap.find('.part-time-form-elems').removeAttr("lay-verify");

		var theTypeBoxClass = null
		if (val == 2) {
			theTypeBoxClass = '.part_time_otype_imgs'
		} else if (val == 3) {
			theTypeBoxClass = '.part_time_otype_imgtexts'
		} else if (val == 4) {
			theTypeBoxClass = '.part_time_otype_mps'
		}else if (val == 5) {
			theTypeBoxClass = '.part_time_otype_reds'
		}
		if (theTypeBoxClass) {
			var $theTypeBox = $itemWrap.find(theTypeBoxClass)
			$theTypeBox.show()
		}
		form.render();
	});
});
</script>
<script type="text/javascript">
	layui.use('layer', function(){
		var layer = layui.layer;
	}); 

	$('#addPeople').on('click',function(){
		layer.open({
			type: 2,
			title: '请选择使用人员',
			shadeClose: true,
			shade: 0.2,
			area: ['700px', '530px'],
			content: 'select_user.html'
		}); 
	})

	layui.use('form', function(){
		var form = layui.form;
		// 自动标签
	form.on('switch(autoLable)', function(data){
	  console.log(data.elem.checked); //是否被选中，true或者false
	  if(data.elem.checked == true){
	  	$("#autoLableContainer").show();
	  }else{
	  	$("#autoLableContainer").hide();
	  }
	  form.render();
	});
	// 欢迎语
	form.on('switch(welcome)', function(data){
	  if(data.elem.checked == true){
	  	$("#welcomeContainer").show();
	  }else{
	  	$("#welcomeContainer").hide();
	  }
	  form.render();
	});
	//监听提交
	form.on('submit(formDemo)', function(data){
	    var edit_hy_text_content_div = $("#edit_hy_text_content_div").html();
	    $("#welcome_text").val(edit_hy_text_content_div);
		var formData = $('#form1').serialize();	
		// console.log(formData);return false;
		myAjaxPost(false, true, '', formData, function (resp) {
			console.log(resp);
			if (resp.status == 'success') {
				tusi(resp.msg);
				setTimeout(function(){
					location.href = 'index.html'; 
				},2000);
			}else{
				alert(resp.msg);
			}
		});
		return false;
	});
});
	function select_img(a){
		var targetId=a.getAttribute('data-target');
		layer.open({
			title:'图片库',
			type: 2,
			area: ['700px', '450px'],
			fixed: false, //不固定
			maxmin: false,
			content: '/imgLib/lib.html?type=vshop_img&target='+targetId
		});
	}

	window.uploadImgCallback=function (tgt,url) {
		console.log('选择图片结果',tgt,url);
		if(tgt=='image'){
			var inputEle=$('#image');
			var prevEle=$('#pic_image');
			inputEle.val(url);
			prevEle.attr('src',url);
			prevEle.show();
		}else if(tgt=='link_pic'){
			var inputEle=$('#link_pic');
			var prevEle=$('#pic_link_pic');
			inputEle.val(url);
			prevEle.attr('src',url);
			prevEle.show();
		}else if(tgt=='miniprogram_pic'){
			var inputEle=$('#miniprogram_pic');
			var prevEle=$('#pic_miniprogram_pic');
			inputEle.val(url);
			prevEle.attr('src',url);
			prevEle.show();
		}else if(tgt.indexOf('part_time_') > -1){ // 分时段 通用
			var inputEle=$('#' + tgt);
			var prevEle=$('#preview_' + tgt);
			inputEle.val(url);
			prevEle.attr('src',url);
			prevEle.show();
		}
	};

	$('#addLable').on('click',function(){
		layer.open({
		  type: 2,
		  title: '请选择标签',
		  shadeClose: true,
		  shade: 0.2,
		  area: ['700px', '530px'],
		  content: 'select_tag.html'
		}); 
	})
</script>

	<script type="text/javascript">
		
	// 在光标位置插入html代码，如果dom没有获取到焦点则追加到最后
     window.onload= function(){
            function insertAtCursor(jsDom, html) {
            if (jsDom != document.activeElement) { // 如果dom没有获取到焦点，追加
                jsDom.innerHTML = jsDom.innerHTML + html;
                return;
            }
            var sel, range;
            if (window.getSelection) {
                // IE9 或 非IE浏览器
                debugger
                sel = window.getSelection();
                if (sel.getRangeAt && sel.rangeCount) {
                    range = sel.getRangeAt(0);
                    range.deleteContents();
                    // Range.createContextualFragment() would be useful here but is
                    // non-standard and not supported in all browsers (IE9, for one)
                    var el = document.createElement("div");
                    el.innerHTML = html;
                    var frag = document.createDocumentFragment(),
                        node, lastNode;
                    while ((node = el.firstChild)) {
                        lastNode = frag.appendChild(node);
                    }
                    range.insertNode(frag);
                    // Preserve the selection
                    if (lastNode) {
                        range = range.cloneRange();
                        range.setStartAfter(lastNode);
                        range.collapse(true);
                        sel.removeAllRanges();
                        sel.addRange(range);
                    }
                }
            } else if (document.selection && document.selection.type != "Control") {
                // IE < 9
                document.selection.createRange().pasteHTML(html);
            }
        }
 
        //  点击插入
       document.getElementById('insert').onclick = function() {
            var html = '<font style="color: green;">用户昵称</font>&nbsp;';
            insertAtCursor(document.getElementById('edit_hy_text_content_div'), html);
        };
    }
	</script>
</html>